import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

const  router =new Router({
    routes:[
        {
            path:'/login',
            component: ()=>import('../views/Login.vue'),
        },
        {
            path:'/register',
            component: ()=>import('../views/Register.vue'),
        },
        {
            path:'/',
            redirect:"/login"
        },
        {
            path:'/back',
            component: ()=>import('../views/back/Back'),
        },
        {
            path: '/shopcart',
            component: () => import('../views/front/shopCart'),
        },
        {
            path: '/shopdetail/:id',
            name: "Shopdetail",
            component: () => import('../views/front/shopDetail'),
        },
        {
            path: '/front',
           redirect:'/front/home',
            component: () => import('../views/front/Front'),
            children: [
                {
                    path: 'home',
                    name: "Home",
                    component: () => import('../views/front/Home'),
                },
                {
                    path: 'personal_center',
                    name: "Personal_center",
                    component: () => import('../views/front/Personal_center'),
                },
            ]
        },
        {
            path: '/phone',
            component: () => import('../views/phone/Phone'),
            meta:{
                title: "首页"
            },
            children:[
                {
                    path: 'login',
                    component: () => import('../views/phone/Login'),
                    meta:{
                        title: "登录"
                    }
                },
                {
                    path: 'home',
                    component: () => import('../views/phone/Home'),
                    meta:{
                        title: "主页"
                    }
                },
                {
                    path: 'myCenter',
                    component: () => import('../views/phone/MyCenter'),
                    meta:{
                        title: "个人中心"
                    }
                },
                {
                    path: 'podcast',
                    component: () => import('../views/phone/Podcast'),
                    meta:{
                        title: "播客"
                    }
                },
            ]
        },

    ]
})


router.afterEach((to) => {
    document.title = to.meta.title || '默认名'    //修改网页的title
})


export default router;